package com.sina.shop.controller.menu;

import com.sina.shop.domain.menu.Menu;
import com.sina.shop.service.menu.MenuService;
import com.sina.shop.web.BaseController;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * 段浩杰   2018-04-12-18:32
 */
@Controller
@RequestMapping("/shop-web/menu")
public class MenuController extends BaseController {

    @Autowired
    private MenuService menuService;

    @RequestMapping(value = "/getMenu", method = RequestMethod.GET)
    public ModelAndView getMenu() {
        ModelAndView mv = new ModelAndView("commonView");
        Map<String, Object> data = new HashMap<>(4);
        Map<String, Object> result = new HashMap<>(6);
        List<Menu> menuList = menuService.getMenu();

        data.put("menuList", menuList);
        result.put(CODE, OK);
        result.put(DATA, data);
        mv.addObject(RESULT, result);

        return mv;
    }


}
